#!/usr/bin/make -f

package=summary-edit
docdir=/share/doc/$(package)
root=debian/tmp

build:
	$(checkdir)

clean:
	rm -fr *~ $(root) debian/*~ debin/files* debian/substvars

binary-indep:	checkroot build
	$(checkdir)

binary-arch:	checkroot build
	rm -fr $(root)
	install -d $(root)/DEBIAN\
		-d $(root)/usr$(docdir)\
		-d $(root)/usr/share/emacs/site-lisp\
		-d $(root)/usr/share/emacs/site-lisp/$(package)\
		-d $(root)/usr/lib/emacsen-common/packages/install/\
		-d $(root)/usr/lib/emacsen-common/packages/remove/\
		-d $(root)/etc/emacs/site-start.d
	cp s*.el $(root)/usr/share/emacs/site-lisp/$(package)/.
	rm -f *.elc
	cp debian/60summary-edit.el $(root)/etc/emacs/site-start.d
	cp debian/install $(root)/usr/lib/emacsen-common/packages/install/$(package)
	chmod 755 $(root)/usr/lib/emacsen-common/packages/install/$(package)
	cp debian/remove $(root)/usr/lib/emacsen-common/packages/remove/$(package)
	chmod 755 $(root)/usr/lib/emacsen-common/packages/remove/$(package)
	install -m 755 debian/postinst $(root)/DEBIAN
	cp debian/copyright $(root)/usr/share/doc/$(package)
	dpkg-gencontrol
	chown -R root.root $(root)
	chmod -R g-ws $(root)
	dpkg --build $(root) ..
	rm -fr $(root)

define checkdir
	test -f debian/rules
endef

binary:	binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"

.PHONY:	binary binary-arch binary-indep clean checkroot
